package main

import (
	"encoding/json"
	"fmt"
	"middle/middleware"

	"net/http"
)

type Company struct {
	ID      int
	Name    string
	Country string
}

func main() {
	a := new(middleware.AuthMiddleware)
	fmt.Println(*a)

	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte("Hello world,,,"))
	})

	http.HandleFunc("/companies", func(w http.ResponseWriter, r *http.Request) {
		c := Company{
			ID:      123,
			Name:    "Google",
			Country: "USA",
		}

		enc := json.NewEncoder(w)
		enc.Encode(c)
	})

	// http.ListenAndServe("localhost:8080", new(middleware.AuthMiddleware))
	// http.ListenAndServe("localhost:8080", a)

	// http.ListenAndServeTLS("localhost:8080", "cert.pem", "key.pem", new(middleware.AuthMiddleware))
	http.ListenAndServeTLS("localhost:8080", "cert.pem", "key.pem", nil)
}
